package com.study.design.pattern.pattern.structural.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: gongsl
 * @Date: 2025-03-16 11:46
 * @description: 棋子单元工厂类
 */
public class ChessPieceUnitFactory {
    private static final Map<Integer, ChessPieceUnit> PIECE_UNIT_MAP = new HashMap<>();

    static {
        PIECE_UNIT_MAP.put(1, new ChessPieceUnit(1, "车", ChessPieceUnit.Color.BLACK));
        PIECE_UNIT_MAP.put(2, new ChessPieceUnit(2, "马", ChessPieceUnit.Color.BLACK));
        // 省略摆放其他棋子的代码
    }

    public static  ChessPieceUnit getChessPiece(int chessPieceId){
        return PIECE_UNIT_MAP.get(chessPieceId);
    }
}

